package com.gamejelly.broker.processor.message;

import com.alipay.remoting.AsyncContext;
import com.alipay.remoting.BizContext;
import com.alipay.remoting.rpc.protocol.AsyncUserProcessor;
import com.gamejelly.broker.message.RpcMessage;
import com.gamejelly.broker.server.BrokerServer;
import com.gamejelly.broker.server.BrokerServerAware;

public class ServerRpcHandler extends AsyncUserProcessor<RpcMessage> implements BrokerServerAware {


    BrokerServer server;

    @Override
    public void handleRequest(BizContext bizContext, AsyncContext asyncContext, RpcMessage rpcMessage) {
        try {
            server.send(rpcMessage);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }


    @Override
    public String interest() {
        return RpcMessage.class.getName();
    }


    @Override
    public void setServer(BrokerServer server) {
        this.server=server;
    }
}
